import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:s_mankey/config/resource_mananger.dart';

///搜索控件widget
class SearchBar extends StatefulWidget {

  Function callBack; //点击搜索回调
  TextEditingController controller;

  SearchBar({this.callBack, this.controller});

  @override
  State<StatefulWidget> createState() => new _SearchBar();
}

class _SearchBar extends State<SearchBar> {

  @override
  void initState() {
    super.initState();
  }

  Widget build(BuildContext context) {
    return
      Row(
        children: [
          Expanded(child: Container(
            margin: EdgeInsets.fromLTRB(15, 0, 15, 0),
            height: 35,
            decoration: BoxDecoration(
                color: Color(0xfff4f5f7),
                borderRadius: BorderRadius.circular(30)),
            child: new Row(
              crossAxisAlignment: CrossAxisAlignment.center,
              children: <Widget>[
                Padding(
                  padding: const EdgeInsets.only(left: 5),
                  child: Icon(
                    Icons.search,
                    color: Colors.grey,
                    size: 20,
                  ),
                ),

                Expanded(child: TextField(
                  controller: widget.controller,
                  decoration: new InputDecoration(
                      contentPadding: EdgeInsets.fromLTRB(10, 0, 10, 11),
                      hintText: '请输入手机号查询',
                      border: InputBorder.none),
                  // onChanged: onSearchTextChanged,
                ),),


                Padding(
                  padding: const EdgeInsets.only(right: 15),
                  child: GestureDetector(
                    onTap: () {
                      widget.controller.clear();
                    },
                    child: Icon(
                      Icons.close,
                      size: 18,
                    ),
                  ),
                ),

              ],
            ),
          ),),

          Padding(
            padding: const EdgeInsets.only(right: 10),
            child: GestureDetector(
              onTap: widget.callBack,
              child: Text('搜索'),
            ),
          ),
        ],
      );

  }
}



//          Container(
//            height: 300,
//            child: Column(children: [
//              Container(
//                height: 300,
//                  color: Colors.white,
////          margin: EdgeInsets.fromLTRB(0, 10, 0, 10),
//                  child: Text('未搜索到用户, 不可分享',style: TextStyle(fontSize: AppFontSize.Size16),)),
//              Expanded(child: Card(child: ListView.builder(
//                  physics: NeverScrollableScrollPhysics(),
//                  itemCount: datas['list'].length, itemBuilder: (BuildContext context, int index){
//                return
//                  Container(
//                    height: 300,
//                    margin: EdgeInsets.fromLTRB(15, 0, 0, 0),
//                    padding: EdgeInsets.fromLTRB(0, 15, 0, 15),
//                    decoration: BoxDecoration(border: Border(bottom: BorderSide(color: AppColor.dividerColor))),
//                    child: Row(
//                      crossAxisAlignment: CrossAxisAlignment.start,
//                      children: [
//                        Image.network('http://monkey.invision.asia/D40_m_t.jpg?t=201908111930',width: 82, height: 117, fit: BoxFit.fill,),
//
//                        Expanded(child:  Padding(
//                          padding: const EdgeInsets.only(left: 3),
//                          child: Column(
//                            crossAxisAlignment: CrossAxisAlignment.center,
//                            children: [
//                              //标题
//                              Row(
//                                mainAxisAlignment: MainAxisAlignment.spaceBetween,
//                                children: [
//                                  Row(children: [
//                                    Text('我是标题'),
//                                    IconFonts.rightIcon,
//                                  ],),
//                                  Icon(Icons.check,size: 15,),
//                                ],),
//
//                              //内容
//                              Container(
//                                padding: EdgeInsets.fromLTRB(0, 5, 0, 5),
//                                child: Text(
//                                  datas['list']['ACCMCC']['type_short_desc'],style: TextStyle(color: Color(0xff747474),
//                                    fontSize: AppFontSize.Size14),
//                                  softWrap: true,
//                                  maxLines: 3,
//                                ),
//                              ),
//
//                              Row(children: [
//                                Text('上课时间：',style: TextStyle(color: Color(0xff9d9d9d),fontSize: AppFontSize.Size14),),
//                                Text(datas['list']['ACCMCC']['course_date'],style: TextStyle(color: Color(0xff494949),fontSize: AppFontSize.Size14),),
//                              ],),
//                            ],
//                          ),
//                        ),),
//
//                      ],),
//                  );
//              }),)),
//
//            ],),
//          ),


